package com.gmail.blackdog1987.onedollar.task;

import com.gmail.blackdog1987.onedollar.service.LuckyBagService;
import com.gmail.blackdog1987.onedollar.service.OrderService;
import com.gmail.blackdog1987.onedollar.service.SmsService;
import com.gmail.blackdog1987.onedollar.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class Task {
	@Autowired
	private SmsService smsService;
	@Autowired
	private UserService userService;
	@Autowired
	private OrderService orderService;
	@Autowired
	private LuckyBagService luckyBagService;

//	@Scheduled(cron = "0/5 * * * * *")
//	public synchronized void job(){
//		smsService.doSendSMS();
//	}

	@Scheduled(cron = "0 0 0 * * ?")
	public synchronized void dataUpdate(){
		userService.updateTodayIncome();
	}

//	@Scheduled(cron = "0 0/5 * * * ?")
//	public synchronized void cleanOneDollarOrder(){
//		System.err.print("cleanOneDollarOrder...");
//		orderService.deleteNotPayOneDollarOrder();
//	}

	@Scheduled(cron = "0 0/1 * * * *")
	public synchronized void deleteNotPayOneDollarOrder(){
//		System.err.print("deleteNotPayOneDollarOrder...");
		orderService.deleteNotPayOneDollarOrder();
//		orderService.updateOneDollarWinner();
	}

	@Scheduled(cron = "0 0 0 * * *")
	public synchronized void getBackLuckyBag(){
//		System.err.print("getBackLuckyBag...");
		luckyBagService.doGetBackNotReceive();
	}
}
